from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
    url(r'^users/$', views.UserView.as_view()),  # 注册
    # url(r'^authorizations/$', obtain_jwt_token),  # 登录
    url(r'^authorizations/$', views.UserLoginView.as_view()),  # 登录,合并购物车
    # 接收客户端数据
    # 创建序列化器对象，
    # 验证数据，通过用户名密码判断用户对象是否存在，存在返回用户对象，否则返回None， 重写ModelBackend.authenticate

    url(r'^user/$', views.UserDetailView.as_view()),  # 用户中心
    url(r'^email/$', views.EmailView.as_view()),  # 设置邮箱
    url(r'^emails/verification/$', views.VerifyEmailView.as_view()),  # 邮箱验证
    url(r'^browse_histories/$', views.UserBrowsingHistoryView.as_view()),  # 用户浏览历史记录

]

router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')

urlpatterns += router.urls
